<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>高校管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		 /*
		  *统一设置所有条目的
		  */
		  function setItemCheckBox(flag) {
		    $(":checkbox[name=compChecked]").prop("checked",flag);
		  }
		  $(function () {
		    //点击全选
		    $("#selectAll").click(function(){
		      //1.获取全选的状态
		      var flag = this.checked;//获取全选的状态
		      if(flag){
		        $(this).prop("checked", true);
		      }else{
		        $(this).prop("checked", false);
		      }
		      //var flag = $(":checkbox[name=selectAll]").attr("checked");//jquery-1.5.1的用法
		      //2.让所有条目的复选框与全选的状态同步
		      //alert(flag);
		      setItemCheckBox(flag);
		    });
		    //给所有复选框添加事件
		    $(":checkbox[name=compChecked]").click(function(){
		      var flagV = this.checked;
		      if(flagV){
		        $(this).prop("checked", true);
		      }else{
		        $(this).prop("checked", false);
		      }
		      //获取所有复选框的个数
		      var len = $(":checkbox[name=compChecked]").length;
		      //获取所有被选中的复选框的个数
		      var checked_len = $(":checkbox[name=compChecked]:checked").length;
		      if(len == checked_len){
		        //alert("全选中了");
		        $("#selectAll").prop("checked",true);
		      } else if(checked_len == 0) {
		        $("#selectAll").prop("checked",false);
		      } else {
		        $("#selectAll").prop("checked",false);
		      }
		    });
		  });
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function submitCheck(){
			$("#checkForm").submit();
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/college/baseCollege/">大学列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="baseCollege" action="${ctx}/compCollege/comp/search" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>学校名称：</label>
				<form:input path="collegeName" htmlEscape="false" maxlength="255" class="input-medium"/>
				<input type="hidden" name="companyId" value="${companyId}"/>
			</li>
			<li><label>学校标识码：</label>
				<form:input path="collegeCode" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>所属省：</label>
				<form:select path="provinceId" class="input-xlarge required">
					<form:options items="${fns:getProvinceList()}" itemLabel="provinceName" itemValue="id" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>分类：</label>
			<sys:treeselect id="baseCategory" name="categoryId" value="${baseCollege.categoryId}" labelName="baseCollege.categoryName" labelValue="${baseCollege.categoryName}"
					title="分类" url="/category/baseCategory/treeData?categoryTypeVal=2"   cssClass="required" allowClear="true"/>
			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
				<button  class="btn btn-primary" type="button"  onclick="javascript:submitCheck()">提交选择</button>
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>学校名称</th>
				<th>所属省</th>
				<th>办学层次</th>
				<th>分类名称</th>
				<th>全选<input type="checkbox" id="selectAll"/>   </th>
			</tr>
		</thead>
		<form:form  action="${ctx}/compCollege/comp/save" method="post" id="checkForm" class="breadcrumb form-search">
		<tbody>
		<c:forEach items="${page.list}" var="cmpCollegeBean">
			<tr>
				<td><a href="${ctx}/college/baseCollege/form?opt=detail&id=${cmpCollegeBean.baseCollege.id}">
					${cmpCollegeBean.baseCollege.collegeName}</a>
				</td>
				<td>
					${cmpCollegeBean.baseCollege.provinceName}
				</td>
				<td>
					${cmpCollegeBean.baseCollege.level}
				</td>
				<td>
					${cmpCollegeBean.baseCollege.categoryName}
				</td>
				<td>
					<input type="checkbox" name="compChecked" value="${cmpCollegeBean.baseCollege.id}"      <c:if test="${cmpCollegeBean.isChecked==1}">checked="checked"</c:if> />
					<input value="${cmpCollegeBean.bizCompany.id}" name="compIds" type="hidden"/>
				</td>
			</tr>
		</c:forEach>
		</tbody>
		</form:form>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>